package com.contest.ws;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

@Configuration
@EnableWebMvc
@EnableWebSocket
public class WebSocketConfig extends WebMvcConfigurerAdapter implements WebSocketConfigurer {
    public void registerWebSocketHandlers(WebSocketHandlerRegistry webSocketHandlerRegistry) {
        //客服聊天室（一对一）
        webSocketHandlerRegistry.addHandler(new WsChatWebSocketHandler(),"/serverChat").setAllowedOrigins("*").addInterceptors(new WsServerChatHandlerInterceptor());
        //聊天室
        webSocketHandlerRegistry.addHandler(new WsChatWebSocketHandler(),"/wsChat").setAllowedOrigins("*").addInterceptors(new WsChatHandlerInterceptor());
        //荒野行动
        webSocketHandlerRegistry.addHandler(new WsPushGamingData(),"/gamingData").setAllowedOrigins("*").addInterceptors(new WsPushDataInterceptor());
        //王者荣耀
        webSocketHandlerRegistry.addHandler(new WsPushGamingDataForKing(),"/gamingDataForKing").setAllowedOrigins("*").addInterceptors(new WsPushDataForKingInterceptor());
        //英雄联盟
        webSocketHandlerRegistry.addHandler(new WsPushGamingDataForHero(),"/gamingDataForHero").setAllowedOrigins("*").addInterceptors(new WsPushDataForHeroInterceptor());
    }
}
